/*package com.hy.mydesktop.client.component.factory;

import java.util.ArrayList;
import java.util.List;

import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.widget.Component;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Layout;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.google.gwt.user.client.ui.AbstractImagePrototype;
import com.test.client.component.meta.GridSetModulesEnum;
import com.test.client.component.meta.GxtComponentMetaNodeModel;
import com.test.client.component.meta.WindowModelEnum;
import com.test.client.component.type.ComponentTypeEnum;
import com.test.shared.rpc.util.ComponentTypeEnumConverter;

*//**
 * 
 * <ul>
 * <li>开发作者：花宏宇</li>
 * <li>设计日期：2010-9-21；时间：下午03:05:22</li>
 * <li>类型名称：FormModuleFactory</li>
 * <li>设计目的：创建表单组件</li>
 * </ul>
 * <ul>
 * <b>修订编号：</b>
 * <li>修订日期：</li>
 * <li>修订作者：</li>
 * <li>修订原因：</li>
 * <li>修订内容：</li>
 * </ul>
 *//*
public class GridSetModulesFactory2 {

	public static ContentPanel createGridModule(
			GxtComponentMetaNodeModel gxtComponentMetaNodeModel) {
		return configureFormPanel(gxtComponentMetaNodeModel);
*//**
 * 
 *//*
	}

	
	private static ContentPanel configureFormPanel(
			GxtComponentMetaNodeModel gxtComponentMetaNodeModel) {

		ContentPanel contentPanel = createDefaultContentPanel();
		
		 
		 *//**
		  * 是否有Grid被添加到当前容器
		  * GxtComponentMetaNodeModel node3 = new GxtComponentMetaNodeModel(map3);
		List<GxtComponentMetaNodeModel> list = new ArrayList<GxtComponentMetaNodeModel>();
		list.add(node3);
		map2.put("gridlist", list);
		  *//*
		 if (gxtComponentMetaNodeModel.get(GridSetModulesEnum.GRIDLIST.name()
					.toLowerCase()) != null) {
			 List<GxtComponentMetaNodeModel> list = (List<GxtComponentMetaNodeModel>) gxtComponentMetaNodeModel.get(GridSetModulesEnum.GRIDLIST.name().toLowerCase());
			 //遍历GxtComponentMetaNodeModel的子节点，即GRIDLIST中的GxtComponentMetaNodeModel
			 for (GxtComponentMetaNodeModel subGxtComponentMetaNodeModel : list) {
				 //createBaseGxtComponent 
				 //表格与树形表格进行分支判断
					contentPanel.add(createBaseGxtComponent(subGxtComponentMetaNodeModel));
			}

		}
		 //高度
		if (gxtComponentMetaNodeModel.get(GridSetModulesEnum.HIGHT.name()
				.toLowerCase()) != null) {
			Integer height = (Integer) gxtComponentMetaNodeModel
					.get(GridSetModulesEnum.HIGHT.name().toLowerCase());
			contentPanel.setHeight((int) height);

		}
		//宽度
		if (gxtComponentMetaNodeModel.get(GridSetModulesEnum.WIDTH.name()
				.toLowerCase()) != null) {
			Integer width = (Integer) gxtComponentMetaNodeModel
					.get(GridSetModulesEnum.WIDTH.name().toLowerCase());
			contentPanel.setWidth((int) width);

		}
		//按钮的对齐方式
		if (gxtComponentMetaNodeModel.get(GridSetModulesEnum.BUTTONALIGN
				.name().toLowerCase()) != null) {
			String buttonAlin = ((String) gxtComponentMetaNodeModel
					.get(GridSetModulesEnum.BUTTONALIGN.name().toLowerCase()))
					.toUpperCase();
			if (buttonAlin.equals("CENTER")) {
				contentPanel.setButtonAlign(HorizontalAlignment.CENTER);
			}else if (buttonAlin.equals("LEFT")) {
				contentPanel.setButtonAlign(HorizontalAlignment.LEFT);
			}
		}
		//折叠
		if (gxtComponentMetaNodeModel.get(GridSetModulesEnum.COLLAPSIBLE
				.name().toLowerCase()) != null) {
			Boolean collapsible = (Boolean) gxtComponentMetaNodeModel
					.get(GridSetModulesEnum.COLLAPSIBLE.name().toLowerCase());
			contentPanel.setCollapsible((boolean) collapsible);

		} 
		//设置背景boolean
		if (gxtComponentMetaNodeModel.get(GridSetModulesEnum.FRAME.name()
				.toLowerCase()) != null) {
			Boolean frame = (Boolean) gxtComponentMetaNodeModel
					.get(GridSetModulesEnum.FRAME.name().toLowerCase());
			contentPanel.setFrame((boolean) frame);

		}
		//标题是否可见
		if (gxtComponentMetaNodeModel.get(GridSetModulesEnum.HEADERVISIBLE
				.name().toLowerCase()) != null) {
			Boolean headerVisible = (Boolean) gxtComponentMetaNodeModel
					.get(GridSetModulesEnum.HEADERVISIBLE.name().toLowerCase());
			contentPanel.setHeaderVisible(headerVisible);

		}
		//标题
		if (gxtComponentMetaNodeModel.get(GridSetModulesEnum.HEADING.name()
				.toLowerCase()) != null) {
			String text = (String) gxtComponentMetaNodeModel
					.get(GridSetModulesEnum.HEADING.name().toLowerCase());
			contentPanel.setHeading(text);

		} 
		if (gxtComponentMetaNodeModel.get(GridSetModulesEnum.LAYOUT.name()
				.toLowerCase()) != null) {
			ComponentTypeEnum componentTypeEnum = (ComponentTypeEnum) gxtComponentMetaNodeModel.get(GridSetModulesEnum.LAYOUT.name()
					.toLowerCase());
	
			Layout layout=null;
	
			switch (componentTypeEnum) {
	            case FITLAYOUT_MODEL:
	            		layout=FitLayoutFactory.createFitLayout(gxtComponentMetaNodeModel);
	            		contentPanel.setLayout(layout);
	                break;
	            case ACCORDIONLAYOUT_MODEL:
	                	layout=AccordionLayoutFactory.createAccordionLayout(gxtComponentMetaNodeModel);
	                	contentPanel.setLayout(layout);
	                break;
	            case ROWLAYOUT_MODEL:
	                	layout=RowLayoutFactory.createRowLayout(gxtComponentMetaNodeModel);
	                	contentPanel.setLayout(layout);
	                break;
	            case VBOXLAYOUT_MODEL:
	                	layout=VboxLayoutFactory.createVboxLayout(gxtComponentMetaNodeModel);
	                	contentPanel.setLayout(layout);
	                break;
	            case COLUMNLAYOUT_MODEL:
	                	layout=ColumnLayoutFactory.createColumnLayout(gxtComponentMetaNodeModel);
	                	contentPanel.setLayout(layout);
	                break;
	            case FLOWLAYOUT_MODEL:
	                	layout=FlowLayoutFactory.createFlowLayout(gxtComponentMetaNodeModel);
	                	contentPanel.setLayout(layout);
	                break;
	            case TABLELAYOUT_MODEL:
	                	layout=TableLayoutFactory.createTableLayout(gxtComponentMetaNodeModel);
	                	contentPanel.setLayout(layout);
	                break;
	            case FORMLAYOUT_MODEL:
	                	layout=FormLayoutFactory.createFormLayout(gxtComponentMetaNodeModel);
	                	
	                	contentPanel.setLayout(layout);
	                break;
	            default:
	                break;
	        }

		} 
		if (gxtComponentMetaNodeModel.get(GridSetModulesEnum.ICON.name()
				.toLowerCase()) != null) {
			AbstractImagePrototype icon = (AbstractImagePrototype) gxtComponentMetaNodeModel
					.get(GridSetModulesEnum.ICON.name().toLowerCase());
			contentPanel.setIcon(icon);

		}
		//自动调整宽度
		if (gxtComponentMetaNodeModel.get(GridSetModulesEnum.AUTOWIDTH.name()
				.toLowerCase()) != null) {
			boolean autoWidth=(Boolean)gxtComponentMetaNodeModel.get(GridSetModulesEnum.AUTOWIDTH.name()
					.toLowerCase());
			contentPanel.setAutoWidth(autoWidth);
		}
		//自动调整高度
		if (gxtComponentMetaNodeModel.get(GridSetModulesEnum.AUTOHEIGHT.name()
				.toLowerCase()) != null) {
			boolean autoHeight=(Boolean)gxtComponentMetaNodeModel.get(GridSetModulesEnum.AUTOHEIGHT.name()
					.toLowerCase());
			contentPanel.setAutoHeight(autoHeight);

		}
		//添加按钮
		if(gxtComponentMetaNodeModel.get(GridSetModulesEnum.ADDBUTTON.name()
				.toLowerCase()) != null){
			List<GxtComponentMetaNodeModel> list=(List<GxtComponentMetaNodeModel>)gxtComponentMetaNodeModel.get(GridSetModulesEnum.ADDBUTTON.name()
					.toLowerCase());
			for(int i=0;i<list.size();i++)
			{
				Button button=ButtonFactory.createButton(list.get(i));
		
				contentPanel.addButton(button);
			}			
		}
		return contentPanel;
	}

	private static ContentPanel createDefaultContentPanel() {

		ContentPanel contentPanel = new ContentPanel();
		return contentPanel;
	}
	
	@SuppressWarnings("unchecked")
	private static <COMPONENT extends Component> COMPONENT createBaseGxtComponent(
			GxtComponentMetaNodeModel gxtComponentMetaNodeModel) {
		//BaseModel gxtComponentMetaModel=null;
		
		COMPONENT component = null;
		ComponentTypeEnum componentTypeEnum = null;		
		if (gxtComponentMetaNodeModel.getComponentTypeEnumIndex()!=0) {
			componentTypeEnum = 	ComponentTypeEnumConverter.getComponentTypeEnum(gxtComponentMetaNodeModel.getComponentTypeEnumIndex());

			
		}else {
			Object object = gxtComponentMetaNodeModel.get("component_model_type");
			
			if (object instanceof Integer) {
				Integer componentTypeEnumIndex = (Integer)gxtComponentMetaNodeModel.get(WindowModelEnum.LAYOUT.name().toLowerCase());	
				componentTypeEnum = 	ComponentTypeEnumConverter.getComponentTypeEnum(componentTypeEnumIndex);
			}else {
				componentTypeEnum = (ComponentTypeEnum)object;
			}
		}
		
		
		switch (componentTypeEnum) {
			//判别具体选择哪种表格，普通表格还是树形表格
			case TREEGRIDMODULE_MODEL: {
				component = (COMPONENT) TreeGridModuleFactory.TreeGridModule(gxtComponentMetaNodeModel);
				break;
			}
			case GRIDMODULE_MODEL: {
				component = (COMPONENT) GridModuleFactory.GridModule(gxtComponentMetaNodeModel);
				break;
			}
			
			default: {//当componentTypeEnum为空，或者与现有控件类型不符合时
				component = null;
				break;
			}
			}
			return component;
	}
	
}*/
